package com.youlai.jdk;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

/**
 * 发行日期：2021年9月
 * 引入了Pattern Matching for switch
 * 引入了Sealed Classes和Interfaces的改进
 * @author zc
 * @date 2023-03-25 22:44
 */
@ExtendWith(VectorExtension.class)
public class Java17 {

    /**
     * 改进的Switch语句：支持使用新的关键字case、
     * yield和arrow简化switch语句的编写
     */
    @Test
    public void switchExpression() throws ClassNotFoundException {
        int num = 2;
        String result = switch (num) {
            case 1 -> "One";
            case 2 -> {
                yield "Two";
            }
            case 3 -> "Three";
            default -> "Other";
        };
        System.out.println(result); // 输出"Two"
    }

    /**
     * Project Loom使用示例
     */
    @Test
    public void projectLoom() throws InterruptedException {
//        Thread thread = Thread.startVirtualThread(() -> {
//            System.out.println("Hello from a virtual thread!");
//        });
//        thread.join();
    }


}
